/* 
 * File:   chemical_element.cpp
 * Author: jolo
 * 
 * Created on: 11. Oktober 2011, 08:17
 * Lincense: New BSD License (The BSD 2-Clause License)
 */

#include "chemical_element.hpp"

namespace model
{

    chemical_element::chemical_element(const string& s,
                                       const string& n,
                                       const string& d,
                                       const string& g,
                                       const string& p,
                                       const double aw,
                                       const int num,
                                       repository* r)
    : standard_in_repository_entity(n, d, r),
    symbol_(s),
    group_(g),
    period_(p),
    atomic_weight_(aw),
    number_(num)
    {
    }

    chemical_element::~chemical_element()
    {
    }

    const string chemical_element::to_string() const
    {
        stringstream s;
        s << object_name() << ": " << symbol() << "[" << number() << "]"
                << ": " << group() << "/" << period() << ": M="
                << atomic_weight() << "u"
                << ": " << standard_in_repository_entity::to_string();
        return s.str();
    }
    
    const string chemical_element::short_label() const {
        return symbol();
    }
    
    const string chemical_element::object_name() const {
        return "Element";
    }
    
    string_vector chemical_element::field_sequence() const {
        string_vector r;
        r.push_back("Symbol");
        r.push_back("Name");
        r.push_back("Number");
        r.push_back("Group");
        r.push_back("Period");
        r.push_back("Atomic Weight");
        r.push_back("Description");
        r.push_back("UUID");
        return r;
    }
    
    string_map chemical_element::field_values() const {
        string_map m;
        m["Symbol"] = symbol();
        m["Name"] = name();
        m["Number"] = entity::to_string(number());
        m["Group"] = group();
        m["Period"] = period();
        m["Atomic Weight"] = entity::to_string(atomic_weight());
        m["Descrption"] = description();
        m["UUID"] = entity::to_string(uuid());
        return m;
    }
}